<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /*
      1. 属性的增强
    */

    var name = 'why'
    var age = 18
    var key = 'address'
    // var ojb = { name: name, age: age }
    // key和value一样时,可以省略
    var obj = {
      name,
      age,
      [key]: '广州', // 计算属性名
      running: function () {
        console.log(this)
      },
      swimming() {
        console.log(this)
      },
      eating: () => {
        console.log(this)
      },
    }
    obj.running()
    obj.swimming()
    obj.eating()
    console.log(obj)

    function foo() {
      var message = 'Hello World'
      var info = 'my name is why'
      return { message, info }
    }
  </script>
</body>

</html>